package com.bocai.yuweiwangluo.activity;


import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;

import com.bocai.yuweiwangluo.R;
import com.bocai.yuweiwangluo.base.BaseActivity;
import com.bocai.yuweiwangluo.presenter.RegistPresenter;
import com.bocai.yuweiwangluo.viewModel.IRegistView;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;

/**
 * 注册
 */
public class RegistActivity extends BaseActivity implements View.OnClickListener,IRegistView
{

    @ViewInject(R.id.et_regist_nick)
    EditText etnick;
    @ViewInject(R.id.et_regist_tel)
    EditText ettel;
    @ViewInject(R.id.et_regist_pwd)
    EditText etpwd;
    @ViewInject(R.id.et_regist_code)
    EditText etcode;
    @ViewInject(R.id.et_regist_pwdtrue)
    EditText etpwdtrue;
    @ViewInject(R.id.et_regist_invitation)
    EditText etinvitation;
    @ViewInject(R.id.btn_regist_getcode)
    Button btngetcode;
    @ViewInject(R.id.btn_regist)
    Button btnregist;
    @ViewInject(R.id.cb_regist)
    CheckBox cb_regist;
    @ViewInject(R.id.tv_agreement)
    TextView tvAgreementp;
    private RegistPresenter registPresenter;
    @Override
    protected int contentView()
    {
        return R.layout.activity_regist;
    }

    @Override
    protected void setData()
    {
        ViewUtils.inject(this);
        initToolbar("注册");
        getRegistPresenter();
        initEvent();
    }

    @Override
    protected void initEvent()
    {
        super.initEvent();
        btngetcode.setOnClickListener(this);
        btnregist.setOnClickListener(this);
        tvAgreementp.setOnClickListener(this);
    }


    @Override
    public void onClick(View v)
    {
        switch (v.getId())
        {
            case R.id.btn_regist_getcode:
                registPresenter.getCode();
                break;
            case R.id.btn_regist:
                registPresenter.verificationCode();
                break;
            case R.id.tv_agreement:
                //跳转到用户协议界面
                startActivity(new Intent(this,AgreementActivity.class ));
                break;
        }
    }


    @Override
    public String getTel()
    {
        return ettel.getText().toString();
    }

    @Override
    public String getPwd()
    {
        return etpwd.getText().toString();
    }

    @Override
    public String getNick()
    {
        return etnick.getText().toString();
    }

    @Override
    public String getCode()
    {
        return etcode.getText().toString();
    }

    @Override
    public String getPwdtrue()
    {
        return etpwdtrue.getText().toString();
    }

    @Override
    public String getInvitation()
    {
        return etinvitation.getText().toString();
    }

    @Override
    public void finishActivity()
    {
        this.finish();
    }

    @Override
    public boolean isChecked()
    {
        return cb_regist.isChecked();
    }

    @Override
    public RegistPresenter getRegistPresenter()
    {
        registPresenter=new RegistPresenter(this,this,btngetcode,this);
        return registPresenter ;
    }
}
